package com.yhp.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.system.common.pojo.BisNurseType;
import com.yhp.service.BisNurseTypeService;

@Controller
@RequestMapping("bnt")
public class BisNurseTypeController {
	@Autowired
	private BisNurseTypeService typeService;
	
	/**
	 * 分类>>>>>>查询所有
	 * @param model
	 * @param typeName
	 * @return
	 */
	@RequestMapping("type")
	public String type(Model model,String typeName){
		Map<String, Object> map=new HashMap<>();
		if (typeName!=null&&!typeName.trim().equals("")) {
			map.put("typeName", typeName);
			model.addAttribute("typeName", typeName);
		}
		List<BisNurseType> bisNurseTypeList = typeService.selectByExample(map);
		model.addAttribute("bisNurseTypeList", bisNurseTypeList);
		return "bis_nurse/type";
	}
	
	/**
	 * 分类>>>>>>添加
	 * @param bisNurseType
	 * @return
	 */
	@RequestMapping("type_add")
	public String type_add(BisNurseType bisNurseType,HttpSession session){		
		typeService.insert(bisNurseType,session);
		return"redirect:/bnt/type";
	}
	
	/**
	 * 分类>>>>>>修改
	 * @param bisNurseType
	 * @return
	 */
	@RequestMapping("type_update")
	public String type_update(BisNurseType bisNurseType,HttpSession session){
		typeService.updateByPrimaryKey(bisNurseType,session);
		return "redirect:/bnt/type";
	}
	
	/**
	 * 分类>>>>>>删除
	 * @param typeId
	 * @return
	 */
	@RequestMapping("type_del")
	public String type_del(String typeId){
		typeService.deleteByPrimaryKey(typeId);
		return "redirect:/bnt/type";
	}
}
